// MARK: - 多协议
protocol ProtocolA {}
protocol ProtocolB {}
class SomeClass: ProtocolA, ProtocolB {}
func process(obj: ProtocolA & ProtocolB) {}

// MARK: - associatedtype
protocol SomeProtocol {
    associatedtype SomeType
    var someProperty: SomeType { get }
}
class A: SomeProtocol {
    typealias SomeType = Int
    var someProperty: Int {
        return 100
    }
}
class B: SomeProtocol {
    typealias SomeType = Double
    var someProperty: Double {
        return 0.0025
    }
}

// MARK: - 协议扩展 & 默认实现
protocol BaseProtocol {
    func hello()
}
extension BaseProtocol {
    func hello() {
        print("Hello Protocol")
    }
}
class MyClass: BaseProtocol {}
let myClass = MyClass()
//myClass.hello()

// MARK: - 协议类型约束
protocol RequiredProtocol {}
extension BaseProtocol where Self: RequiredProtocol {
    func helloHello() {
        print("Hello Hello Protocol")
    }
}
class OK: BaseProtocol, RequiredProtocol{}
let ok = OK()
ok.hello()
ok.helloHello()
class NotOK: BaseProtocol {}
let notOK = NotOK()
notOK.hello()
